package cn.talkimages.web;

import org.apache.commons.lang3.StringUtils;

import com.opensymphony.xwork2.ActionProxy;

public class WebNavAction extends WebPageAction {

	private static final long serialVersionUID = -1991180248027625909L;

	/**
	 * 判断是否和当前Context的Action一致
	 * 
	 * @param actionId
	 * @return boolean
	 */
	public boolean matchCurrentActionId(String actionId) {

		return StringUtils.equals(getCurrentActionId(), actionId);
	}

	/**
	 * 判断是否和当前Context的ActionID是否已参数ActionId开头
	 * 
	 * @param actionId
	 * @return boolean
	 */
	public boolean startWithActionId(String actionId) {
		return StringUtils.startsWith(getCurrentActionId(), actionId);
	}

	/**
	 * 获得当前访问Action ID
	 * 
	 * @return String
	 */
	public String getCurrentActionId() {

		ActionProxy proxy = getActionContext().getActionInvocation().getProxy();

		return StringUtils.join(proxy.getNamespace(), "/",
				proxy.getActionName());
	}
}
